﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/EduConfig/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '配置名称', name: 'ConfigName', width: 250, align: 'left' },
                {
                    label: '配置值', name: 'ConfigValue', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        if ((top.clients.dataItems["submitType"][cellvalue] != undefined) && (top.clients.dataItems["submitType"][cellvalue] != "")) {
                            return top.clients.dataItems["submitType"][cellvalue];
                        }
                        if ((top.clients.dataItems["registerType"][cellvalue] != undefined) && (top.clients.dataItems["registerType"][cellvalue] != "")) {
                            return top.clients.dataItems["registerType"][cellvalue];
                        }    
                    }
                },
                { label: '配置说明', name: 'ConfigContent', width: 250, align: 'left' },
            ],
            pager: "#gridPager",
            sortname: 'F_CreatorTime asc',
            viewrecords: true
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增配置",
            url: "/Gas/EduConfig/Form",
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_update() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        var ConfigName = $("#gridList").jqGridRowValue().ConfigName;
        console.log(ConfigName);
        if (keyValue == null || keyValue == "") {
            alert("请选择想要修改的配置信息");
            return;
        }
        //通过ConfigName来切换不同的form
        if ("submit_status" == ConfigName) {
            $.modalOpen({
                id: "Update",
                title: "信息修改",
                url: "/Gas/EduConfig/submitForm?keyValue=" + keyValue,
                width: "550px",
                height: "570px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();//提交表单
                }
            });
        }

        if ("register_status" == ConfigName) {
            $.modalOpen({
                id: "Update",
                title: "信息修改",
                url: "/Gas/EduConfig/registerForm?keyValue=" + keyValue,
                width: "550px",
                height: "570px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();//提交表单
                }
            });
        }
        
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" onclick="btn_update()"><i class="fa fa-pencil-square-o"></i>修改</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>